/*
ID:luongho3
LANG:C++
TASK:ariprog
*/
#include <iostream>
#include <fstream>
#include <algorithm>

using namespace std;
#define MAX_M 350
ifstream fin("ariprog.in");
ofstream fout("ariprog.out");
int t_array[MAX_M*MAX_M], bis[MAX_M*MAX_M];
int mark[MAX_M*MAX_M];
int N,M;
int b_len, t_len;
void read() {
     fin>>N>>M;
     int i,j,k;
     k = 0;
     for (i=0;i<=M;++i) {
         for (j=i;j<=M;++j) {
             int temp = i*i + j*j;
             if (mark[temp]!= 1) {
                bis[k] = temp;
                ++k;
                mark[temp] = 1;
             }                
         }
     }
     b_len = k;
     sort(bis, bis + b_len);
}
bool isBis(int n) {
     if (n > bis[b_len-1]) return false;
     else if (mark[n] == 1) return true;
     else return false;
}
bool isProg(int start, int offset, int p_len) {
     int i;
     for (i=0;i<p_len;++i) {
         if (!isBis(start + i*offset)) {
            return false;
         }
     }
     return true;
}
struct prog {
       int start;
       int offset;
};
bool cmp(prog a, prog b) {
     if (a.offset != b.offset) return (a.offset < b.offset);
     else return a.start < b.start;     
}
prog results[10000];
int r_len = 0;
void solve() {
     int i,j,offset;
     for (i=0;i<=b_len-N;++i) {
         for (j=i+1;j<=b_len-N+1;++j) {
             offset = bis[j] - bis[i];
             if (bis[i] + (N-1)*offset > bis[b_len - 1])
                continue;
             if (isProg(bis[i], offset, N)) {
                prog t_prog;
                t_prog.start = bis[i];
                t_prog.offset = offset;
                results[r_len] = t_prog;
                ++r_len;
             }
         }
     }
}
void print_out() {
     if (r_len == 0) {
        fout<<"NONE\n";
     }
     int i;
     for (i=0;i<r_len;++i) {
         fout<<results[i].start << " " <<results[i].offset<<"\n";
     }
}
int main() {
    read();
    
    /*for (int i=0;i<b_len;++i) {
        fout << bis[i] << "\n";
    }*/
    solve();
    sort(results, results + r_len, cmp);
    print_out();
    return 0;
}
